class Solution(object):
    def isPalindrome(self, s):
        """
        :type s: str
        :rtype: bool
        """
        begin = 0
        end = len(s)-1
        while begin<end:
            while begin<end and s[begin].isalnum()==False: begin+=1
            while begin<end and s[end].isalnum()==False: end-=1
            if begin<end:
                if s[begin].lower()==s[end].lower():
                    begin+=1
                    end-=1
                else:
                    return False
        return True